﻿<%@ page language="C#" autoeventwireup="true" CodeFile="InformationUtilizationTop20.aspx.cs" inherits="Topo_InformationUtilizationTop20" enableEventValidation="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>信息利用率TOP20</title>
    <link href="../App_Themes/CSS/default.css" rel="stylesheet" type="text/css" />
    <link href="../JS/ext-3.0.0/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
    <script src="../JS/ext-3.0.0/adapter/ext/ext-base.js" type="text/javascript"></script>
    <script src="../JS/ext-3.0.0/ext-all.js" type="text/javascript"></script>
    <script type="text/javascript">
        var count = '20'; //排行数目
        Ext.onReady(function () {
            Ext.BLANK_IMAGE_URL = '../JS/ext-3.0.0/resources/images/default/s.gif';
            Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
            var data = Topo_InformationUtilizationTop20.GetModelList(count).value;
            var length = parseInt(count) / 2; //单个排行长度
            var myDataLeft = []; var myDataRight = []; //左右数据集
            var len = data.length;
            for (var i = 0; i < len; i++) {
                if (i < length) {
                    myDataLeft.push(data[i]);
                }
                else {
                    myDataRight.push(data[i]);
                }
            }
            var sortIndex = 1;
            var reader = new Ext.data.ArrayReader({}, new Ext.data.Record.create([{ name: "LAID", mapping: "LAID", type: "string" }, { name: "NODEID", mapping: "NODEID", type: "string" },
                        { name: "NODENAME", mapping: "NODENAME", type: "string" },
                        { name: "TYPE", mapping: "TYPE", type: "string" },
                        { name: "UTILIZATION", mapping: "UTILIZATION", type: "string" }
                    ]));
            var gridDataLeft = new Ext.data.Store({
                proxy: new Ext.data.MemoryProxy(myDataLeft),
                reader: reader
            });
            gridDataLeft.load();

            //多选按钮
            // var check = new Ext.grid.CheckboxSelectionModel();
            //Grid的表头
            var cm = new Ext.grid.ColumnModel([
                 new Ext.grid.RowNumberer({
                     header: "序号",
                     width: 20,
                     renderer: function () {
                         if (sortIndex > 20) {
                             sortIndex = 1;
                         }
                         return sortIndex++;
                     }
                 }), //Grid的序号
            //check, //多选框
                 {header: "基站编号", width: 65, height: 10, sortable: true, dataIndex: "LAID" },
                 { header: "基站名", width: 55, height: 10, sortable: true, dataIndex: "NODENAME" },
                 { header: "% 信道平均占用", width: 100, height: 10, sortable: true, dataIndex: "UTILIZATION" }
            ]);
            var gridleft = new Ext.grid.GridPanel({
                renderTo: 'InformationUtilizationTop20Left',
                ds: gridDataLeft, //数据内容
                cm: cm, //表头
                columnLines: true,
                stripeRows: true,
                height: 300,
                width: 248
                // ,sm: check //添加多选按钮的地方
            });
            gridleft.getSelectionModel().on('rowselect', function (sm, rowIdx, r) {
                rowSelected(sm, rowIdx, r);
            });

            var gridDataRight = new Ext.data.Store({
                proxy: new Ext.data.MemoryProxy(myDataRight),
                reader: reader
            });
            gridDataRight.load();
            var gridright = new Ext.grid.GridPanel({
                renderTo: 'InformationUtilizationTop20Right',
                ds: gridDataRight, //数据内容
                cm: cm, //表头
                columnLines: true,
                stripeRows: true,
                height: 300,
                width: 248,
                listeners: {
                    rowdblclick: function (grid, row) {
                        tbsChannelUsageLink();
                    }
                }
            });
            gridright.getSelectionModel().on('rowselect', function (sm, rowIdx, r) {
                rowSelected(sm, rowIdx, r);
            });
            //表格行单击事件
            function rowSelected(sm, rowindex, r) {
                var id = r.data.NODEID;
                var o = window.frames.parent;
                o.document.getElementById('CurrentTBS').innerHTML = '当前基站：' + r.data.NODENAME + '&nbsp;&nbsp;-&nbsp;&nbsp;' + r.data.UTILIZATION;
                o.document.getElementById('hidSelectedTBSID').value = id; //在父页面保存选中的基站的ID
                o.document.getElementById('ifCurrentStation').src = 'InformationCurrentStation.aspx?neid=' + id;
                o.document.getElementById('ifCurrentStat').src = 'InformationCurrentStationStat.aspx?neid=' + id;
            }

            function reLoadGrid() {
                try {
                    data = Topo_InformationUtilizationTop20.GetModelList(count).value; //获取原数据
                    //清空数据集
                    myDataLeft = [];
                    myDataRight = [];
                    //重新分配数据集
                    for (var i = 0; i < len; i++) {
                        if (i < length) {
                            myDataLeft.push(data[i]);
                        }
                        else {
                            myDataRight.push(data[i]);
                        }
                    }
                    //重新加载数据集
                    gridleft.getStore().loadData(myDataLeft);
                    gridright.getStore().loadData(myDataRight);
                    //                    gridDataLeft.load();
                    //                    gridDataRight.load();
                    //                    gridleft.getStore().reload();
                    //                    gridright.getStore().reload();
                    // alert('加载成功');
                } catch (e) {
                    // alert('加载失败');
                }
            }

            setInterval(reLoadGrid, 10000); //界面数据10秒钟更新一次
            //setInterval(reLoadGrid, 5000);
        });
        function tbsChannelUsageLink() {
            var url = 'TBSChannelLinkIndex.htm';
            window.open(url, 'tbsChannelDetail', 'directorys=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=850,height=620,left=20,top=10');
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="InformationUtilizationTop20Left">
    </div>
    <div id="InformationUtilizationTop20Right" style="position: absolute; left: 250px;
        top: 0px;">
    </div>
    </form>
</body>
</html>
